<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../share/taglib.jsp" %>
<html>
<head>
<title>评论<bean:message key="display.manage"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/css/vip.css" type="text/css">
<script language="JavaScript">
//到指定的分页页面
function topage(page){
	var form = document.forms[0];
	form.page.value=page;
	form.submit();
}

function deleteComments(url, needConfirm) {
	var cs = document.getElementsByName("commentIds");
	var checkNo = 0;
	for (var i = 0; i < cs.length; i++) {
		if(cs[i].checked) {
			checkNo++;
		}
	}
	if (checkNo == 0) {
		alert('尚未选中任何记录');
		return false;
	}
	
	if (needConfirm) {
		if(!confirm('此操作将会一并删除该评论下的所有回复，你确定要删除选中的评论吗？')) {
			return false;
		}
	}
	var form = document.getElementById('houseForm');
	form.action = url;
	form.method.value = 'delete';
	form.submit();
}
function goEdit(type) {
   var form = document.getElementById('houseForm');
   if (type == 'Comment') {
      form.action = '/cms/house/comment.do';
   	  form.method.value = 'list';
   } else {
   	  form.method.value = 'editUI';
   }
   form.type.value = type;
   form.submit();
}
function checkAllComment(obj) {
	var cs = document.getElementsByName("commentIds");
	for (var i = 0; i < cs.length; i++) {
		cs[i].checked = obj.checked;
	}
}
function revert(commentId) {
	window.showModalDialog("/cms/house/comment.do?method=listRevert&commentId="+commentId+"&ts=" + new Date().getTime(), window, "center=yes");
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" marginwidth="0" marginheight="0">
<html:form action="/cms/house.do" styleId="houseForm" method="post">
<html:hidden property="page"/>
<html:hidden property="houseId"/>
<html:hidden property="type"/>
<html:hidden property="method" value="list"/>
  <table width="90%" border="0" cellspacing="1" cellpadding="2" align="center">
    <tr bgcolor="#ffbe26">
    	<td colspan="7">
    		<table width="98%">
				<tr>
					<td width="80%">
						&nbsp;&nbsp;<a href="javascript:goEdit('Base');"><font color="#000000">房源信息</font></a>&nbsp;&nbsp;
						|&nbsp;&nbsp;<a href="javascript:goEdit('Trans');"><font color="#000000">交易信息</font></a>&nbsp;&nbsp;
						|&nbsp;&nbsp;<font color="#000000">评论列表</font>&nbsp;&nbsp;
						|&nbsp;&nbsp;<a href="/cms/uploadFile.do?method=listH&objType=house&objId=${houseForm.houseId}"><font color="#000000">图片列表</font></a>&nbsp;&nbsp;
						|&nbsp;&nbsp;<a href="/cms/uploadFile.do?method=listVideo&objType=house&objId=${houseForm.houseId}"><font color="#000000">视频列表</font></a>&nbsp;&nbsp;
					</td>
				</tr>
			</table>
    	</td>
    </tr>
    <tr><td colspan="6"  bgcolor="#ffbe26" align="right">
    	<%@ include file="../share/fenye.jsp" %>
	</td></tr>
	<tr>
	  <td width="5%" bgcolor="#ffbe26"><input type="checkbox" onclick="checkAllComment(this);" name="checkAll"/></td>
      <td width="5%" bgcolor="#ffbe26"><div align="center"><font color="#000000"><bean:message key="display.number"/></font></div></td>
      <td width="10%" bgcolor="#ffbe26"><div align="center"><font color="#000000">用户</font></div></td>
      <td width="60%" bgcolor="#ffbe26"><div align="center"><font color="#000000">内容</font></div></td>
      <td width="10%" bgcolor="#ffbe26"><div align="center"><font color="#000000">发表时间</font></div></td>
      <td width="5%" nowrap bgcolor="#ffbe26">
      	<div align="center"><font color="#000000">回复</font></div>
      </td>
    </tr>
<!---------------------------LOOP START------------------------------>
<c:forEach items="${pageView.records}" var="entry">
    <tr>
      <td bgcolor="f5f5f5"><input type="checkbox" name="commentIds" value="${entry.commentId}"/></td>
      <td bgcolor="f5f5f5"><div align="center">${entry.commentId}</div></td>
      <td bgcolor="f5f5f5"><div align="center">${entry.users.userName}</div></td>
      <td bgcolor="f5f5f5"><div align="center">${entry.content}</div></td>
      <td bgcolor="f5f5f5"><div align="center">${entry.publishTime}</div></td>
	  <td bgcolor="f5f5f5"><div align="center">
	  	<img src="/images/feedback.png" style="cursor:hand;" width="15" height="16" border="0" onClick="javascript:revert(${entry.commentId});"></div>
	  </td>
	</tr>
</c:forEach>
    <!----------------------LOOP END------------------------------->
    <tr>
      <td colspan="6" nowrap bgcolor="#ffbe26" align="left">
      	<table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td width="5%"></td>
              <td width="85%">
              <input type="button" <c:if test="${fn:length(pageView.records) == 0}">disabled="disabled"</c:if> onClick="javascript:deleteComments('/cms/house/comment.do', true);" value="删除">&nbsp;&nbsp;
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</html:form>
</body>
</html>